<template>
	<div class="operatePassenger train">
		<trainHeader :name="title"></trainHeader>
		<div class="operatePassenger_studentTip" v-show="type">
			学生寒暑假出行可购买指定坐席的票，且需持有效学生证件取票，请确保乘车区段与学生证优惠区间保持一致，否则无法取票~
		</div>
		<!--表单-->
		<div class="operatePassenger_content">
			<div class="operatePassenger_input">
				<div class="operatePassenger_title">姓名</div>
				<input v-model="value.name" placeholder="请填写正确的姓名" :disabled="message.passengerTypeisno == 1"/>
			</div>
			<div class="operatePassenger_input">
				<div class="operatePassenger_title">乘客类型</div>
				<div class="operatePassenger_message" @click="changeOption(1)">
					<span v-if="type">学生票</span>
					<span v-else>成人票</span>
				</div>
				<img src="http://h5.kpcx179.com/wximages/train/gengduo@2x.png" alt="" class="operatePassenger_move" />
			</div>
			<div class="operatePassenger_input operatePassenger_sex">
				<div class="operatePassenger_title">性别</div>
				<div class="operatePassenger_message operatePassenger_message_sex">
					<div @click="changeSex(0)">
						<img src="../../../assets/train/yuan-weixuanze@2x.png" alt="" v-if="value.sex" />
						<img src="../../../assets/train/yuan-yixuanze@2x.png" alt="" v-else/>
						<span>男</span>
					</div>
					<div @click="changeSex(1)">
						<img src="../../../assets/train/yuan-yixuanze@2x.png" alt="" v-if="value.sex" />
						<img src="../../../assets/train/yuan-weixuanze@2x.png" alt="" v-else/>
						<span>女</span>
					</div>
				</div>
			</div>
			<div class="operatePassenger_input" v-show="!type">
				<div class="operatePassenger_title">证件类型</div>
				<div class="operatePassenger_message" @click="changeOption(2)">
					<span v-if="certType==0">身份证</span>
					<span v-else-if="certType==1">护照</span>
					<span v-else-if="certType==2">台胞证</span>
					<span v-else-if="certType==3">港澳台通行证</span>
				</div>
				<img src="http://h5.kpcx179.com/wximages/train/gengduo@2x.png" alt="" class="operatePassenger_move" />
			</div>
			<div class="operatePassenger_input" v-show="!type">
				<div class="operatePassenger_title">证件号码</div>
				<input type="" name="" id="" value="" v-model="value.number" placeholder="请填写正确的证件号码" @input="getIDnumber" :disabled="message.passengerTypeisno == 1"/>
			</div>
			<div class="operatePassenger_input" v-show="type">
				<div class="operatePassenger_title">身份证号</div>
				<input type="" name="" id="" value="" v-model="value.IDnumber" placeholder="请填写正确的证件号码" @input="getIDnumber" :disabled="message.passengerTypeisno == 1"/>
			</div>
			<div class="operatePassenger_input">
				<div class="operatePassenger_title" v-if="message.passengerTypeisno == 1">出生日期</div>
				<div class="operatePassenger_message" v-if="message.passengerTypeisno == 1">
					{{value.birthday}}
				</div>
				<div class="operatePassenger_message" v-else>
					<group class="ids">
						<datetime v-model="value.birthday" title="出生日期"></datetime>
					</group>
				</div>
				<img src="http://h5.kpcx179.com/wximages/train/gengduo@2x.png" alt="" class="operatePassenger_move" />
			</div>
			<div class="operatePassenger_zhan" v-show="!type">
				<div></div>
			</div>
			<div class="operatePassenger_input">
				<div class="operatePassenger_title">联系电话</div>
				<input v-model="value.phone" placeholder="用于接受确认短信" />
			</div>
			<div v-show="type">
				<div class="operatePassenger_zhan">
					<div></div>
				</div>
				<div class="operatePassenger_input">
					<div class="operatePassenger_title">学号</div>
					<input :disabled="message.passengerTypeisno == 1" v-model="value.studentID" placeholder="请填写正确的学号" />
				</div>
				<div class="operatePassenger_input">
					<div class="operatePassenger_title">学制</div>
					<div class="operatePassenger_message" @click="changeOption(3)">
						<span v-if="value.schoolSys">{{value.schoolSys}}年制</span>
						<span v-else style="color: #999;">请选择学制</span>
					</div>
					<img src="http://h5.kpcx179.com/wximages/train/gengduo@2x.png" alt="" class="operatePassenger_move" />
				</div>
				<div class="operatePassenger_input">
					<div class="operatePassenger_title">入学年份</div>
					<div class="operatePassenger_message" @click="changeOption(4)">
						<span v-if="value.enterSchool < 0" style="color: #999;">请选择入学年份</span>
						<span v-else>{{enterSchoolArr[value.enterSchool]}}年</span>
					</div>
					<img src="http://h5.kpcx179.com/wximages/train/gengduo@2x.png" alt="" class="operatePassenger_move" />
				</div>
				<div class="operatePassenger_input">
					<div class="operatePassenger_title">学校省份</div>
					<div class="operatePassenger_message" @click="skipList(0)">
						<span v-if="value.schoolProvince.name">{{value.schoolProvince.name}}</span>
						<span v-else style="color: #999;">请选择学校省份</span>
					</div>
					<img src="http://h5.kpcx179.com/wximages/train/gengduo@2x.png" alt="" class="operatePassenger_move" />
				</div>
				<div class="operatePassenger_input">
					<div class="operatePassenger_title">学校名称</div>
					<div class="operatePassenger_message" @click="skipList(1)">
						<span v-if="value.schoolName.name">{{value.schoolName.name}}</span>
						<span v-else style="color: #999;">请选择学校名称</span>
					</div>
					<img src="http://h5.kpcx179.com/wximages/train/gengduo@2x.png" alt="" class="operatePassenger_move" />
				</div>
				<div class="operatePassenger_input operatePassenger_shcoolName">
					<div class="operatePassenger_title">优惠区间</div>
					<div class="operatePassenger_section">
						<div class="operatePassenger_message" @click="skipList(2)">
							<span v-if="value.schoolName.name">{{value.homeCity.name}}</span>
							<span v-else style="color: #999;">请选择家乡所在县市</span>
							<img src="http://h5.kpcx179.com/wximages/train/gengduo@2x.png" alt="" class="operatePassenger_move" />
						</div>
						<div class="operatePassenger_message operatePassenger_active" @click="skipList(3)">
							<span v-if="value.schoolName.name">{{value.schoolCity.name}}</span>
							<span v-else style="color: #999;">请选择学校所在县市</span>
							<img src="http://h5.kpcx179.com/wximages/train/gengduo@2x.png" alt="" class="operatePassenger_move" />
						</div>
					</div>
				</div>
			</div>
		</div>
		<!--购票说明-->
		<div class="operatePassenger_tip" v-show="type">
			<p class="operatePassenger_tip_title">学生购票说明</p>
			<p>
				<span>1、</span>
				<span>
					学生票乘车时间限为每年的暑假6月1日至9月30日、寒假 12月1日至3月31日，其他时间需购买成人票。
				</span>
			</p>
			<p>
				<span>2、</span>
				<span>
					学生票仅支持购买硬座、硬卧、二等座、无座等坐席。其他坐席需购买成人票。
				</span>
			</p>
			<p>
				<span>3、</span>
				<span>
					每年乘车次数仅限于四次单程。当年未使用的次数，不能留至下年使用。
				</span>
			</p>
			<p>
				<span>4、</span>
				<span>
					列车出发站和到达站需在优惠乘车区之内，且优惠乘车区间限于家庭至院校（实习地点）之间。若不在优惠区间内则无法取票。
				</span>
			</p>
			<p>
				<span>5、</span>
				<span>
					学生票先收取成人票价，出票后根据票价金额退还差价。差价1-3个工作日原路返回
				</span>
			</p>
		</div>
		<!--完成按钮-->
		<div class="operatePassenger_submit" @click="submit">
			提交
		</div>
		<!--底部选项-->
		<div v-if="bottomList.length" class="operatePassenger_bottom">
			<div v-for="item,index in bottomList" :class="{'active':bottomListActive.active == index}" @click="maskClick(index)">
				{{item}}
			</div>
		</div>
		<kpMask v-show="bottomList.length" @mask='maskClick'></kpMask>
	</div>
</template>
<style scoped>
	.operatePassenger_studentTip {
		background-color: #EED4BD;
		color: #D88442;
		font-size: 28px;
		padding: 15px 30px;
	}
	
	.operatePassenger_content {
		padding-left: 30px;
		background-color: #fff;
	}
	
	.operatePassenger_content input {
		border: 0;
		outline: none;
		width: 100%;
		flex: 1;
		height: 70%;
		font-size: 30px;
		color: #000000;
	}
	
	.operatePassenger_input {
		height: 100px;
		padding-right: 30px;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		border-bottom: 2px solid #e9e9e9;
	}
	
	.operatePassenger_input.operatePassenger_shcoolName {
		height: 200px;
	}
	
	.operatePassenger_section {
		height: 200px;
		display: flex;
		flex-direction: column;
		flex: 1;
	}
	
	.operatePassenger_section>.operatePassenger_message {
		border-bottom: 2px solid #e9e9e9;
	}
	
	.operatePassenger_section>.operatePassenger_message.operatePassenger_active {
		border:0;
	}
	
	.operatePassenger_input.operatePassenger_sex {
		height: 147px;
	}
	
	.operatePassenger_title {
		width: 190px;
		display: flex;
		height: 100%;
		align-items: center;
		font-size: 30px;
		color: #333333;
	}
	
	.operatePassenger_message {
		width: 100%;
		flex: 1;
		height: 100%;
		font-size: 30px;
		color: #000000;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.operatePassenger_message.operatePassenger_message_sex {
		justify-content: flex-start;
	}
	
	.operatePassenger_message_sex>div {
		display: flex;
		height: 100%;
		justify-content: flex-start;
		align-items: center;
		margin-right: 60px;
	}
	
	.operatePassenger_message_sex img {
		width: 34px;
		height: 34px;
		margin-right: 20px;
	}
	
	.operatePassenger_move {
		width: 18px;
		height: 32px;
	}
	
	.operatePassenger_bottom {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		background: #fff;
		z-index: 500;
		border-radius: 8px 8px 0px 0px;
	}
	
	.operatePassenger_bottom>div {
		height: 90px;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 36px;
		color: #333333;
		border-bottom: 2px solid #e1e1e1;
	}
	
	.operatePassenger_bottom>div.active {
		color: #3bc3c2;
	}
	
	.operatePassenger_zhan {
		height: 20px;
		width: 100%;
		position: relative;
		top: 0;
		left: 0;
	}
	
	.operatePassenger_zhan>div {
		background: #F4F5F9;
		position: absolute;
		right: 0;
		top: 0;
		width: 750px;
		height: 100%;
	}
	
	.operatePassenger_tip {
		width: 100%;
		padding: 30px;
		box-sizing: border-box;
		font-size: 26px;
		color: #8a8a8a;
		line-height: 35px;
		padding-bottom: 110px;
	}
	
	.operatePassenger_tip_title {
		font-size: 28px;
		color: #666;
	}
	
	.operatePassenger_tip>p {
		display: flex;
		justify-content: flex-start;
		align-items: flex-start;
		margin-top: 17px;
	}
	
	.operatePassenger_submit {
		width: 100%;
		height: 98px;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 36px;
		color: #fefefe;
		background-color: #3bc3c2;
		position: fixed;
		bottom: 0;
		left: 0;
	}
	
	.operatePassenger input:disabled {
		background: #fff;
	}
</style>
<style>
	.ids {
		width: 100%;
	}
	
	.ids .weui-cells:before {
		border-top: none;
	}
	
	.ids .weui-cells:after {
		border-bottom: none;
	}
	
	.train .ids .vux-datetime {
		color: #333;
		font-size: 30px;
	}
	
	.ids .vux-datetime>div {
		height: 100px;
		display: flex;
		align-items: center;
	}
	
	.ids .vux-no-group-title {
		margin-top: 0;
	}
	
	.ids .weui-cell {
		padding: 0;
		display: flex;
	}
	
	.ids .weui-cell div:first-child {
		flex: 1;
	}
	
	.ids .weui-cell div:nth-child(2) {
		flex: 2;
	}
	
	.ids .weui-cell__ft {
		text-align: left;
	}
	
	.ids .weui-cell_access .weui-cell__ft:after {
		width: 0;
		height: 0;
		border-width: 0;
		border-color: none;
		border-style: none;
	}
	
	.dp-header {
		height: 80px;
	}
	
	.dp-header .dp-item {
		height: 30px;
		line-height: 30px;
	}
	
	.dp-container .dp-header .dp-item {
		font-size: 32px;
		height: 100%;
		display: flex;
		align-items: center;
		padding: 0 30px;
	}
	
	.dp-container .dp-header .dp-item.dp-right {
		justify-content: flex-end;
	}
	
	.ids .vux-cell-value {
		color: #000;
	}
</style>
<script>
	import { Datetime, Group } from 'vux';
	import trainHeader from "../../../components/trainHeader";
	import kpMask from "../../../components/kpmask"; //蒙层
	export default {
		data() { //数据
			return {
				title: "编辑乘客", //标题
				message: {}, //编辑乘客的信息
				type: 0, // 0 成人  1学生 乘客身份
				certType: 0, //证件类型 0身份证 1护照 2台胞 3港澳
				certTypeNum: 1, //后台所需的证件类型
				value: { //输入信息
					name: "", //姓名
					number: "", //证件号
					phone: "", //联系电话
					sex: 0, //性别 0男 1女
					birthday: "请选择", //生日
					IDnumber: "", //身份证号 （学生用）
					studentID: "", //学号
					schoolSys: "", //学制
					enterSchool: -1, //入学年份(索引)
					schoolProvince: { //学校所在省份
						name: '',
						code: 0
					},
					schoolName: { // 学校名称
						name: '',
						code: 0
					},
					homeCity: { // 家乡所在城市
						name: '',
						code: 0
					},
					schoolCity: { // 学校所在城市
						name: '',
						code: 0
					},
				},
				bottomList: [], //底部选项数组
				bottomListActive: {
					type: 1,
					active: 0,
				}, //底部选中数组
				enterSchoolArr: [], //入学年份数组
				passengerTypeisno: 0, //12306乘客
			}
		},
		watch: {
			certType() { //证件类型变更 //1 身份证  2 护照  8台胞  10港澳
				this.certTypeNum = (this.certType == 0) ? 1 : (this.certType == 1) ? 2 : (this.certType == 2) ? 8 : (this.certType == 3) ? 10 : 1;
				this.check = (this.certType == 0) ? this.$publicMethod.checkIDnumber : (this.certType == 1) ? this.$publicMethod.checkPassport : (this.certType == 2) ? this.$publicMethod.checkCompatriots : (this.certType == 3) ? this.$publicMethod.checkHkAndMacao : this.$publicMethod.checkIDnumber;
				var index = -1; //匹配证件
				Array.isArray(this.message.kpcxcertnO) && this.message.kpcxcertnO.forEach((val,key)=>{	
					(this.certTypeNum == val.certTypeNum) && (index = key);
				},this);
				this.value.number = (index == -1) ? "" : this.message.kpcxcertnO[index].certNo;
			},
			type(){//成人学生变更
				this.type && (Array.isArray(this.message.kpcxcertnO) && this.message.kpcxcertnO.forEach((val,key)=>{
					(val.certTypeNum == "1") && (this.value.IDnumber = val.certNo);//成人变更学生匹配身份证
				},this));
			},
		},
		mounted() {
			
		},
		created() {
			if(this.$store.state.train.trainStore.operatePassenger) { ///页面切换
				var operatePassenger = JSON.parse(JSON.stringify(this.$store.state.train.trainStore.operatePassenger));
				Object.keys(operatePassenger).forEach(i => { //页面信息存储使用
					this[i] = operatePassenger[i];
				}, this);
			} else { //首次进入
				this.$store.state.train.trainStore.operatePassengerItem ? (this.message = JSON.parse(JSON.stringify(this.$store.state.train.trainStore.operatePassengerItem))) : (this.title = "添加乘客"); //编辑信息
				this.getEnterSchoolArr();//获取入学年份
				this.getMessage();//处理编辑的乘客信息
			};
		},
		methods: {
			getEnterSchoolArr(){
				var nowYear = new Date().getFullYear();
				var firstYear = nowYear - 10;
				var enterSchoolArr = [];
				for (var i = firstYear; i <= nowYear; i++) {
					enterSchoolArr.push(i);
				};
				this.enterSchoolArr = enterSchoolArr;
			},
			getMessage() { //处理编辑的乘客信息
				if (!this.message.passengerType) return;
//				console.log(this.message);
				if(this.message.bornDate) { //生日做处理
					this.message.bornDate = this.message.bornDate.replace(/年/g, '-');
					this.message.bornDate = this.message.bornDate.replace(/月/g, '-');
					this.message.bornDate = this.message.bornDate.replace(/日/g, ' ');
				};
				//提取公共信息
				this.value.name = this.message.name; //姓名
				this.value.phone = this.message.mobileNo || this.message.phoneNo; //电话
				this.value.sex = Number(this.message.sexCode); //性别
				this.value.birthday = this.message.bornDate; //生日
				this.type = (this.message.passengerType == "3") ? 1 : 0; //乘客类型
				this.passengerTypeisno = this.message.passengerTypeisno; //12306乘客
				this.message.kpcxcertnO.sort((a, b) => { //证件排序
					return Number(a.certType) - Number(b.certType)
				});
				//区分成人和学生（处理证件）
				if(this.type) { //学生
					this.message.kpcxcertnO.forEach((val) => { //证件类型
						var certTypeNum = val.certTypeNum || val.certType;
						(certTypeNum == "1") && (this.value.IDnumber = val.certNo); //身份证
						(certTypeNum == "101" || certTypeNum == "102") && (this.value.studentID = val.certNo); //学号
					},this);
					this.value.schoolSys = this.message.eductionalSystem; //学制
					this.value.enterSchool = this.enterSchoolArr.indexOf(this.message.admissionYear); //入学年份
					(this.value.enterSchool < 0) && (this.value.enterSchool = 0);//防止年份有误
					this.value.schoolProvince.name = this.message.provinceName; //学校省份
					this.value.schoolProvince.code = this.message.provinceCode;
					this.value.schoolName.name = this.message.schoolName; //学校名称
					this.value.schoolName.code = this.message.schoolCode;
					this.value.homeCity.name = this.message.preferenceFromName; //优惠区间（家）
					this.value.homeCity.code = this.message.preferenceFromStation; //优惠区间
					this.value.schoolCity.name = this.message.preferenceToName; //优惠区间（学校）
					this.value.schoolCity.code = this.message.preferenceToStation; //优惠区间
				} else { //成人
					if(!this.message.kpcxcertnO.length) return;
					var certTypeNum = this.message.kpcxcertnO[0].certTypeNum || this.message.kpcxcertnO[0].certType;//证件类型
					if(certTypeNum == "101") return; //只有一个学生证号的成人（bug乘客）
					(certTypeNum == "1") && (this.certType = 0);
					(certTypeNum == "2") && (this.certType = 1);
					(certTypeNum == "8") && (this.certType = 2);
					(certTypeNum == "10") && (this.certType = 3);
					this.value.number = this.message.kpcxcertnO[0].certNo; //证件号码
				};
			},
			check(val) { //证件验证 默认身份证
				return this.$publicMethod.checkIDnumber(val);
			},
			changeSex(num){
				if(this.message.passengerTypeisno) return;
				this.value.sex = num;
			},
			maskClick(index) {
				this.bottomList.length = 0;
				this.$forceUpdate();
				if(index == undefined) return;
				if(this.bottomListActive.type == 1) { //成人学生 
					this.type = index;
				} else if(this.bottomListActive.type == 2) { //证件类型
					this.certType = index;
				} else if(this.bottomListActive.type == 3) { //学制
					this.value.schoolSys = index + 1;
				} else if(this.bottomListActive.type == 4) { //入学年份
					this.value.enterSchool = index;
				} else {};
			},
			changeOption(type) { //修改选项 type 1 成人学生  2证件类型  3 学制  4入学年份
				if(this.message.passengerTypeisno) return;
				this.bottomListActive.type = type;
				if(type == 1) { //成人学生 
					var arr = ["成人票", "学生票"];
					this.bottomListActive.active = this.type;
				} else if(type == 2) { //证件类型
					var arr = ['身份证', '护照', '台胞证', '港澳通行证'];
					this.bottomListActive.active = this.certType;
				} else if(type == 3) { //学制
					var arr = ["1年制", "2年制", "3年制", "4年制", "5年制", "6年制", "7年制", "8年制", "9年制"];
					this.bottomListActive.active = (Number(this.value.schoolSys) - 1) < 0 ? 0 : (Number(this.value.schoolSys) - 1);
				} else if(type == 4) { //入学年份
					var arr = JSON.parse(JSON.stringify(this.enterSchoolArr));
					this.bottomListActive.active = (this.value.enterSchool < 0) ? 0 : this.value.enterSchool;
				} else {};
				this.bottomList = arr;
			},
			submit() { //提交 验证
				var str = "";
				var check = this.check;
				if (this.type) { //学生票添加的校验
					this.value.schoolCity.name || (str = "请选择学校所在城市");
					this.value.homeCity.name || (str = "请选择家乡所在城市");
					this.value.schoolName.name || (str = "请选择学校名称");
					this.value.schoolProvince.name || (str = "请选择学校所在省份");
					(this.value.enterSchool == "-1") && (str = "请选择入学年份");
					this.value.schoolSys || (str = "请选择学制");
					(this.value.studentID === "") && (str = "请填写您的学号");
				};
				(this.type) && (check = this.$publicMethod.checkIDnumber);//学生
				check(this.type ? this.value.IDnumber : this.value.number) || (str = this.type ? "请填写正确的身份证号" : "请填写正确的证件号");
				(this.type ? (this.value.IDnumber === "") : (this.value.number === "")) && (str = this.type ? "请填写您的身份证号" : "请填写您的证件号");
				this.$publicMethod.checkPhoneNum(this.value.phone) || (str = "请填写正确的联系电话");
				(this.value.phone === "") && (str = "请填写您的联系电话");
				(this.value.birthday == "请选择") && (str = "请选择您的生日");
				this.$publicMethod.checkName(this.value.name) || (str = "请填写正确的姓名");
				(this.value.name === "") && (str = "请填写您的姓名");
				str ? (this.$toast(str, {
					durtaion: 200,
					location: 'center',
				})) : this.getSubmit();
			},
			getSubmit() { //提交传参
				var param = {
					name: encodeURI(this.value.name), //姓名
					mobileNo: this.value.phone, //电话
					userID: this.$store.state.common.userinfo.userID, //userId
					// phoneNo: this.value.phone, //电话
					sexCode: String(this.value.sex), //性别
					passengerType: this.type ? '3' : "1", //类型 1成人 3学生
					bornDate: this.value.birthday, //生日
				};
				if(this.type) { //学生
					param.provinceCode = this.value.schoolProvince.code; //学校所在省份
			        param.provinceName = encodeURI(this.value.schoolProvince.name);
			        param.schoolCode = this.value.schoolName.code; //学校名称
			        param.schoolName = encodeURI(this.value.schoolName.name);
			        param.eductionalSystem = this.value.schoolSys; //学制
			        param.admissionYear = this.enterSchoolArr[this.value.enterSchool]; //入学年份
			        param.preferenceFromStation = this.value.homeCity.code; //优惠区间
			        param.preferenceFromName = encodeURI(this.value.homeCity.name); //优惠区间
			        param.preferenceToStation = this.value.schoolCity.code; //优惠区间
			        param.preferenceToName = encodeURI(this.value.schoolCity.name); //优惠区间
			        param.kpcxcertnO = [{ //证件类型
			          certNo: this.value.IDnumber,//身份证
			          certType: "1",
			        }, {
			          certNo: this.value.studentID,//学生证
			          certType: "3",
			        }];
				} else { //成人
					param.kpcxcertnO = [{ //证件类型
						certNo: this.value.number,
						certType: this.certTypeNum,
					}];
				};
				(this.title == "编辑乘客") && (param.Contactsid = this.message.Contactsid || this.message.contactsid);
//				var url = (this.title == "编辑乘客") ? "KPCX/appContacts/updateLocalContacts" : "KPCX/appContacts/saveLocalContacts"; //编辑更改接口
				var url = (this.title == "编辑乘客") ? "kpcx/appContacts/updateLocalContacts" : "kpcx/appContacts/saveLocalContacts"; //编辑更改接口
				this.finish(param, url);
			},
			finish(param, url) { //完成
				this.$loading.show();
				this.$http.post(this.$baseUrl.baseurl + url, param).then((res) => {
					this.$loading.hide();
//					console.log(res);
					(res.data.Code == "0") ? this.$router.go(-1) : this.$toast(res.data.msg, {
						durtaion: 200,
						location: 'center',
					});
				}).catch((err) => {
					this.$loading.hide();
					console.log(err);
				});
			},
			getIDnumber() { //身份证18位计算生日
				if((this.value.number.length == 18 && !this.type) || (this.value.IDnumber.length == 18 && this.type)) {
					var birth = '';
					var IDnumber = this.type ? this.value.IDnumber : this.value.number;
					if(this.$publicMethod.checkIDnumber(IDnumber)) { //正则判断
						birth = IDnumber.substring(6, 14);
						birth = birth.slice(0, 4) + '-' + birth.slice(4, 6) + '-' + birth.slice(6, 8);
						this.value.birthday = birth;
					} else {
						this.$toast("您的身份证号输入有误", {
							durtaion: 200,
							location: 'center',
						});
					};
				};
			},
			skipList(sign){//跳转  0 学校省份  1学校名称  2家乡所在城市  3学校所在城市
				if(this.message.passengerTypeisno) return; //12306乘客不可修改
				this.$router.push({
					name:"trainGetList",
					query:{
						sign,
					}
				})
			}
		},
		beforeRouteLeave(to, from, next) {
			var trainStore = JSON.parse(JSON.stringify(this.$store.state.train.trainStore));
			(to.name == "trainPassenger") ? (trainStore.operatePassenger = null,trainStore.operatePassengerItem = null) : (trainStore.operatePassenger = this._data);
			this.$store.commit('TRAINSTORE', trainStore);
			next();
		},
		components: {
			trainHeader,
			kpMask,
			Datetime,
			Group
		},
	};
</script>